const path = require("path");
const modelsPath = path.join(process.cwd(), "/models");
const fs = require("fs");
const Promise = require("bluebird");
const Password = require("node-php-password");

fs.readdir(modelsPath, function (err, files) {
  console.log(files);
  let loadArray = [];
  for (const file of files) {
    const modelPath = modelsPath + "/" + file;
    // loadArray.push(require(modelPath)());
  }
  Promise.all(loadArray).then((res) => {
    console.log(res);
  });
});
(function (password) {
  const isVerify = Password.verify("123", password);
  console.log(isVerify);
})("$2y$10$sZlpZNoLAnoD1DtYO9REAODCPkpMb5bwl4oMzrMvJa83k9BY3KRwq");

const targetDir = path.join(process.cwd(), "/pic");
const readStream = fs.createReadStream(
  path.join(process.cwd(), "tmp_uploads/283a09fe8a37edef7b4c06777e069339.png")
);
const writeStream = fs.createWriteStream(
  path.join(targetDir, "/283a09fe8a37edef7b4c06777e069339.png")
);
if (!fs.existsSync(targetDir)) {
  fs.mkdir(targetDir, function (err) {
    readStream.pipe(writeStream);
    readStream.on("end", function (err) {
      console.log("--end", err);
    });
  });
}
